<link rel="stylesheet" href="__CDN__/assets/addons/shopro/libs/element/element.css">
<link rel="stylesheet" href="__CDN__/assets/addons/shopro/libs/common.css">
<style>
    #agentIndex {
        color: #444;
        background: #fff;
        padding-bottom: 30px;
        font-size: 12px;
    }


    .shopro-reset-button {
        margin-right: 20px;
    }

    .reject-reason-item {
        width: 140px;
        margin-right: 14px;
    }

    .shopro-edit-cancel {
        color: #848089;
        cursor: pointer;
    }

    .theme-cursor {
        color: #6E3DC8;
        cursor: pointer;
    }

    body .table-image {
        border-radius: 15px;
        width: 30px;
        height: 30px;
        overflow: hidden;
        border: 1px solid #e6e6e6;
    }

    .shopro-refresh-button {
        margin-right: 20px;
        margin-bottom: 20px;
    }

    .shopro-screen-item-vague .shopro-screen-condition {
        width: 242px;
    }

    .shopro-screen-item-vague .el-select {
        width: 100px;
    }

    .agent-apply-item-tip {
        font-size: 12px;
        line-height: 12px;
        color: #58575A;
        margin-bottom: 14px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .agent-apply-item {
        margin-bottom: 20px;
    }

    .agent-apply-item-identity {
        width: 153px;
        min-height: 42px;
        background: #E6E6E6;
        border-radius: 4px;
        overflow: hidden;
        display: flex;
        align-items: center;
    }

    .agent-apply-item-tip-delete {
        color: #F49300;
        cursor: pointer;
        margin-right: 14px;
    }

    .color-ED655F {
        color: #ED655F;
    }

    .theme-cursor {
        color: #6E3DC8;
        cursor: pointer;
    }

    .color-999 {
        color: #999;
    }

    .color-0ACE97 {
        color: #0ACE97;
    }

    .popover-container .table-image-identity {
        width: 100px;
        height: 60px;
        border-radius: 4px;
    }

    .unit-tip-item {
        color: #626066;
        font-size: 12px;
        margin-left: 6px;
        line-height: 18px;
    }

    .nice-validator .el-input__inner {
        vertical-align: baseline !important;
    }

    [v-cloak] {
        display: none
    }
</style>
<script src="__CDN__/assets/addons/shopro/libs/vue.js"></script>
<script src="__CDN__/assets/addons/shopro/libs/element/element.js"></script>
<script src="__CDN__/assets/addons/shopro/libs/moment.js"></script>
<div id="agentIndex" v-cloak v-loading="isAjax">
    <div class="shopro-tabs-container">
        <el-tabs v-model="activeTabsName" @tab-click="tabshandleClick">
            <el-tab-pane v-for="tabs in tabsList" :label="tabs.label" :name="tabs.name"></el-tab-pane>
        </el-tabs>
    </div>
    <div class="shopro-screen-container">
        <div class="shopro-button shopro-refresh-button" @click="getListData">
            <i class="el-icon-refresh"></i>
        </div>
        <div class="display-flex shopro-screen-item shopro-screen-item-vague">
            <div class="shopro-screen-condition">
                <el-input placeholder="请输入内容" v-model="searchForm.form_1_value" class="input-with-select" size="small">
                    <el-select v-model="searchForm.form_1_key" slot="prepend" placeholder="请选择">
                        <el-option label="会员ID" value="user_id"></el-option>
                        <el-option label="会员昵称" value="nickname"></el-option>
                        <el-option label="手机号" value="mobile"></el-option>
                    </el-select>
                </el-input>
            </div>
        </div>
        <div class="display-flex shopro-screen-item">
            <div class="shopro-screen-tip">分销商等级</div>
            <div class="shopro-screen-condition">
                <el-select v-model="searchForm.level" placeholder="请选择" size="small">
                    <el-option v-for="item in agentLevelList" :key="item.level"
                        :label="item.level!='all'?item.name+'(等级'+item.level+')':item.name" :value="item.level">
                        {{item.name}}
                        <span v-if="item.level!='all'">(等级{{item.level}})</span>
                    </el-option>
                </el-select>
            </div>
        </div>
        <div class="display-flex shopro-screen-item" v-if="activeTabsName!='pending'">
            <div class="shopro-screen-tip">审核状态</div>
            <div class="shopro-screen-condition">
                <el-select v-model="searchForm.status" placeholder="请选择" size="small">
                    <el-option v-for="item in agentStatusOptions" :key="item.value" :label="item.label"
                        :value="item.value">
                    </el-option>
                </el-select>
            </div>
        </div>
        <!-- <div class="display-flex shopro-screen-item">
            <div class="shopro-screen-tip">申请时间</div>
            <div>
                <el-date-picker v-model="searchForm.createtime" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss"
                    size="small" format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="开始日期"
                    end-placeholder="结束日期">
                </el-date-picker>
            </div>
        </div> -->
        <div class="display-flex shopro-screen-item">
            <div class="shopro-screen-tip">更新时间</div>
            <div>
                <el-date-picker v-model="searchForm.updatetime" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss"
                    size="small" format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="开始日期"
                    end-placeholder="结束日期">
                </el-date-picker>
            </div>
        </div>
        <div class="display-flex shopro-screen-item-button">
            <div class="shopro-button shopro-reset-button" @click="screenEmpty">重置</div>
            <div class="shopro-button shopro-screen-button" @click="handleCurrentChange(1)">筛选</div>
        </div>
    </div>
    <div class="shopro-table-container" v-loading="isAjaxtable">
        <el-table v-if="activeTabsName=='all'" :data="listData" border stripe :cell-class-name="tableCellClassName"
            :header-cell-class-name="tableCellClassName">
            <el-table-column label="ID" prop="user_id" width="70">
            </el-table-column>
            <el-table-column label="分销商信息" width="220">
                <template slot-scope="scope">
                    <div v-if="scope.row.user" class="display-flex">
                        <div class="table-image">
                            <el-image :src="Fast.api.cdnurl(scope.row.user.avatar)" fit="contain">
                                <div slot="error" class="image-slot">
                                    <i class="el-icon-picture-outline"></i>
                                </div>
                            </el-image>
                        </div>
                        <div class="ellipsis-item">{{scope.row.user.nickname?scope.row.user.nickname:'-'}}</div>
                    </div>
                    <div v-else>-</div>
                </template>
            </el-table-column>
            <el-table-column label="手机号" width="120">
                <template slot-scope="scope">
                    <div v-if="scope.row.user && scope.row.user.mobile">{{scope.row.user.mobile}}</div>
                    <div v-else>-</div>
                </template>
            </el-table-column>
            <el-table-column label="等级" width="160">
                <template slot-scope="scope">
                    <div class="display-flex">
                        <div class="ellipsis-item">
                            <span>{{(scope.row.agent_level &&
                                scope.row.agent_level.name)?scope.row.agent_level.name:'-'}}</span>
                            <span>(等级{{scope.row.level}})</span>
                        </div>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="累计佣金" min-width="100">
                <template slot-scope="scope">
                    <div>{{scope.row.total_income}}<span class="unit-tip-item">元</span></div>
                </template>
            </el-table-column>
            <el-table-column label="消费金额" min-width="100">
                <template slot-scope="scope">
                    <div>{{scope.row.user?scope.row.user.total_consume:'-'}}<span class="unit-tip-item">元</span></div>
                </template>
            </el-table-column>
            <el-table-column label="直推分销业绩" min-width="200">
                <template slot-scope="scope">
                    <div>{{scope.row.order_money}}元/{{scope.row.order_count}}单</div>
                </template>
            </el-table-column>
            <el-table-column label="上级分销商" min-width="140">
                <template slot-scope="scope">
                    <div v-if="scope.row.parent_agent && scope.row.parent_agent_id!=0" class="display-flex"
                        @click="operation('edit',scope.row.parent_agent.id)">
                        <div class="table-image">
                            <el-image :src="Fast.api.cdnurl(scope.row.parent_agent.avatar)" fit="contain">
                                <div slot="error" class="image-slot">
                                    <i class="el-icon-picture-outline"></i>
                                </div>
                            </el-image>
                        </div>
                        <div class="ellipsis-item theme-cursor">
                            {{scope.row.parent_agent.nickname?scope.row.parent_agent.nickname:'-'}}</div>
                    </div>
                    <div style="justify-content: center;" v-else>-</div>
                </template>
            </el-table-column>
            <el-table-column label="一级用户人数" width="120">
                <template slot-scope="scope">
                    <div>
                        <span v-if="scope.row.user">{{scope.row.user.child_user_count_1}}
                            <span class="unit-tip-item">人</span>
                        </span>
                        <span v-else>-</span>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="一级分销商人数" width="120">
                <template slot-scope="scope">
                    <div>{{scope.row.child_agent_count_1}}<span class="unit-tip-item">人</span></div>
                </template>
            </el-table-column>
            <el-table-column fixed="right" label="状态" width="100">
                <template slot-scope="scope">
                    <div class="display-flex">
                        <span v-if="scope.row.status=='normal'" class="display-flex">
                            <span class="shopro-status-dot shopro-status-normal-dot"></span>
                            <span class="shopro-status-normal">{{scope.row.status_text}}</span>
                        </span>
                        <span v-else-if="scope.row.status=='forbidden'" class="display-flex">
                            <span class="shopro-status-dot shopro-status-nonormal-dot"></span>
                            <span class="shopro-status-nonormal">{{scope.row.status_text}}</span>
                        </span>
                        <span v-else-if="scope.row.status=='pending'" class="display-flex">
                            <span class="shopro-status-dot shopro-status-default-dot"></span>
                            <span class="shopro-status-default">{{scope.row.status_text}}</span>
                        </span>
                        <span v-else-if="scope.row.status=='freeze'" class="display-flex">
                            <span class="shopro-status-dot shopro-status-special-dot"></span>
                            <span class="shopro-status-special">{{scope.row.status_text}}</span>
                        </span>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="创建时间" width="150">
                <template slot-scope="scope">
                    <div>
                        {{moment(scope.row.createtime*1000).format("YYYY-MM-DD HH:mm:ss")}}
                    </div>
                </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" min-width="80">
                <template slot-scope="scope">
                    <div class="theme-cursor" @click="operation('edit',scope.row.user_id)">
                        查看
                    </div>
                </template>
            </el-table-column>
        </el-table>
        <el-table v-if="activeTabsName=='pending'" :data="listData" border stripe :cell-class-name="tableCellClassName2"
            :header-cell-class-name="tableCellClassName2">
            <el-table-column label="ID" prop="user_id" width="70">
            </el-table-column>
            <el-table-column label="分销商信息" min-width="240">
                <template slot-scope="scope">
                    <div v-if="scope.row.user" class="display-flex">
                        <div class="table-image">
                            <el-image :src="Fast.api.cdnurl(scope.row.user.avatar)" fit="contain">
                                <div slot="error" class="image-slot">
                                    <i class="el-icon-picture-outline"></i>
                                </div>
                            </el-image>
                        </div>
                        <div class="ellipsis-item">{{scope.row.user.nickname?scope.row.user.nickname:'-'}}</div>
                    </div>
                    <div v-else>-</div>
                </template>
            </el-table-column>
            <el-table-column label="资料审核" width="160">
                <template slot-scope="scope">
                    <div class="platform-name display-flex-c">
                        <el-popover placement="bottom" trigger="hover">
                            <div class="popover-container">
                                <template v-if="scope.row.apply_info!=''">
                                    <div class="display-flex"
                                        :style="{marginBottom: (scope.row.apply_info && JSON.parse(scope.row.apply_info).length-1)>index?'14px':0}"
                                        v-for="(item,index) in JSON.parse(scope.row.apply_info)">
                                        <div class="display-flex">
                                            <div class="popover-tip">{{item.name}}</div>：
                                        </div>
                                        <div v-if="item.type=='input' || item.type=='number'">{{item.value}}</div>
                                        <div class="table-image table-image-identity" v-if="item.type=='image'">
                                            <el-image :src="Fast.api.cdnurl(item.value)" fit="contain">
                                                <div slot="error" class="image-slot">
                                                    <i class="el-icon-picture-outline"></i>
                                                </div>
                                            </el-image>
                                        </div>
                                    </div>
                                </template>
                                <div v-if="!scope.row.apply_info" style="text-align: center;">
                                    -
                                </div>
                            </div>
                            <span class="ellipsis-item cursor-pointer" slot="reference">
                                <span class="color-ED655F" v-if="scope.row.info_status==-1">已驳回</span>
                                <span class="color-999" v-if="scope.row.info_status==0">未完善</span>
                                <span class="color-0ACE97" v-if="scope.row.info_status==1">已完善</span>
                                <span v-if="scope.row.info_status==null">无需资料</span>
                            </span>
                        </el-popover>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="等级" min-width="160">
                <template slot-scope="scope">
                    <div class="display-flex">
                        <div class="ellipsis-item">
                            <span>
                                {{(scope.row.agent_level &&
                                scope.row.agent_level.name)?scope.row.agent_level.name:'-'}}
                            </span>
                            <span>(等级{{scope.row.level}})</span>
                        </div>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="上级分销商" min-width="140">
                <template slot-scope="scope">
                    <div v-if="scope.row.parent_agent && scope.row.parent_agent_id!=0" class="display-flex"
                        @click="operation('edit',scope.row.parent_agent.id)">
                        <div class="table-image">
                            <el-image :src="Fast.api.cdnurl(scope.row.parent_agent.avatar)" fit="contain">
                                <div slot="error" class="image-slot">
                                    <i class="el-icon-picture-outline"></i>
                                </div>
                            </el-image>
                        </div>
                        <div class="ellipsis-item theme-cursor">
                            {{scope.row.parent_agent.nickname?scope.row.parent_agent.nickname:'-'}}
                        </div>
                    </div>
                    <div style="justify-content: center;" v-else>-</div>
                </template>
            </el-table-column>
            <el-table-column label="消费金额" width="140">
                <template slot-scope="scope">
                    <div>{{scope.row.user?scope.row.user.total_consume:'-'}}<span class="unit-tip-item">元</span></div>
                </template>
            </el-table-column>
            <el-table-column label="推广人数" width="140">
                <template slot-scope="scope">
                    <div>
                        <span v-if="scope.row.user">{{scope.row.user.child_user_count_1}}</span>
                        <span v-if="!scope.row.user">-</span>
                        <span class="unit-tip-item">人</span>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="提交次数" width="100">
                <template slot-scope="scope">
                    <div>{{scope.row.apply_num}}<span class="unit-tip-item">次</span>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="更新时间" width="150">
                <template slot-scope="scope">
                    <div>
                        {{moment(scope.row.updatetime*1000).format("YYYY-MM-DD HH:mm:ss")}}
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="创建时间" width="150">
                <template slot-scope="scope">
                    <div>
                        {{moment(scope.row.createtime*1000).format("YYYY-MM-DD HH:mm:ss")}}
                    </div>
                </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" min-width="220">
                <template slot-scope="scope">
                    <div>
                        <span class="theme-cursor" style="margin-right: 14px;"
                            @click="operation('edit',scope.row.user_id)">
                            查看
                        </span>
                        <span style="margin-right: 14px;cursor: pointer;color:#687FF4"
                            v-if="scope.row.info_status==0 || scope.row.info_status==-1"
                            @click="operation('edit',scope.row.user_id)">辅助填写</span>
                        <span class="shopro-edit-text" v-if="scope.row.info_status==0 || scope.row.info_status==1"
                            @click="operation('agree',scope.row.user_id,scope.row)">同意</span>
                        <span class="shopro-edit-text" v-if="scope.row.info_status==null"
                            @click="operation('agree-null-status',scope.row.user_id)">同意</span>
                        <span class="agent-apply-item-tip-delete" v-if="scope.row.info_status==1"
                            @click="operation('reject',scope.row.user_id)">驳回</span>
                        <span class="shopro-delete-text" slot="reference" v-if="scope.row.info_status==1"
                            @click="operation('del',scope.row.user_id)">删除</span>
                    </div>
                </template>
            </el-table-column>
        </el-table>
        <el-table v-if="activeTabsName=='1'" :data="listData" border stripe :cell-class-name="tableCellClassName3"
            :header-cell-class-name="tableCellClassName3">
            <el-table-column label="ID" prop="user_id" width="70">
            </el-table-column>
            <el-table-column label="分销商名称" min-width="240">
                <template slot-scope="scope">
                    <div v-if="scope.row.user" class="display-flex">
                        <div class="table-image">
                            <el-image :src="Fast.api.cdnurl(scope.row.user.avatar)" fit="contain">
                                <div slot="error" class="image-slot">
                                    <i class="el-icon-picture-outline"></i>
                                </div>
                            </el-image>
                        </div>
                        <div class="ellipsis-item">{{scope.row.user.nickname?scope.row.user.nickname:'-'}}</div>
                    </div>
                    <div v-else>-</div>
                </template>
            </el-table-column>
            <el-table-column label="当前等级" min-width="160">
                <template slot-scope="scope">
                    <div class="display-flex">
                        <div class="ellipsis-item">
                            <span>{{(scope.row.agent_level &&
                                scope.row.agent_level.name)?scope.row.agent_level.name:'-'}}</span>
                            <span>(等级{{scope.row.level}})</span>
                        </div>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="升级之后的等级" min-width="160">
                <template slot-scope="scope">
                    <div>{{scope.row.level_status_text?scope.row.level_status_text:'-'}}(等级{{scope.row.level_status}})
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="创建时间" width="160">
                <template slot-scope="scope">
                    <div>
                        {{moment(scope.row.createtime*1000).format("YYYY-MM-DD HH:mm:ss")}}
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="消费金额(元)" min-width="140">
                <template slot-scope="scope">
                    <div>{{scope.row.user?scope.row.user.total_consume:'-'}}<span class="unit-tip-item">元</span></div>
                </template>
            </el-table-column>
            <el-table-column label="推广人数" width="140">
                <template slot-scope="scope">
                    <div>
                        <span v-if="scope.row.user">
                            {{scope.row.user.child_user_count_1}}<span class="unit-tip-item">人</span>
                        </span>
                        <span v-else="scope.row.user">-</span>
                    </div>
                </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" min-width="190">
                <template slot-scope="scope">
                    <div>
                        <span class="shopro-edit-text color-0ACE97" v-if="scope.row.level_status_text"
                            @click="operation('update-agree',scope.row.user_id,scope.row.level_status)">同意</span>
                        <span style="margin-right: 12px;" v-if="!scope.row.level_status_text">未找到等级</span>
                        <span class="shopro-delete-text" v-if="scope.row.level_status!=0"
                            @click="operation('update-refuse',scope.row.user_id,0)">{{scope.row.level_status_text?'拒绝':'删除'}}</span>
                        <span class="shopro-edit-text" @click="operation('edit',scope.row.user_id)">查看</span>
                    </div>
                </template>
            </el-table-column>
        </el-table>
    </div>
    <div class="shopro-pagination-container">
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
            :page-sizes="[10, 20, 30, 40]" :page-size="limit" layout="total, sizes, prev, pager, next, jumper"
            :total="totalPage">
        </el-pagination>
    </div>
</div>